package question1;

import java.io.*;

public class HomeWork3 {

    public static void copy(){
        File file1 = new File("D:\\backup","3.jpg");
        try{
            file1.createNewFile();
            FileInputStream fis = new FileInputStream("F:\\迅雷下载\\DwnlData\\1.jpg");
            DataInputStream dis = new DataInputStream(fis);
            FileOutputStream fos = new FileOutputStream("D:\\backup\\3.jpg");
            try (DataOutputStream dos = new DataOutputStream(fos)) {
                int temp;
                byte[] buf = new byte[1024];

                while ((temp = dis.read(buf)) != -1) {
                    dos.write(buf,0,temp);
                    dos.flush();
                }
                //关闭流
                fis.close();
                dos.close();
            }
        }catch (IOException e){
            e.printStackTrace();

        }
    }




    public static void main(String[] args) {
        copy();
    }
}
